package com.demonzym.dishorder.activity;

import com.demonzym.data.infos.UpdateData;
import com.demonzym.data.trans.ProtocolConst;
import com.demonzym.framework.string.MyString;

import android.content.Context;
import android.content.SharedPreferences;

public class SettingActivity {
	public static final String DESK_ZHULEI = "DESK_ZHULEI";
	public static final String DESK_ZUIDI = "DESK_ZUIDI";
	public static final String DESK_ZHULEIMING = "DESK_ZHULEIMING";
	public static final String DESK_ID = "DESK_ID";
	public static final String IP = "IP";
	
	public static final String PAD_STATE = "PAD_STATE";

	/**
	 * zhuzhuangtai + "$" + cizhuangtai
	 * @param context
	 * @return
	 */
	synchronized public	static String getPadState(Context context)
	{
		SharedPreferences settings = context.getSharedPreferences(context.getPackageName()+"_preferences",
				Context.MODE_PRIVATE);
		String data = settings.getString(PAD_STATE, "0");			
		return data;
	}
	synchronized public	static void setPadState(Context context, String state)
	{
		if(MyString.isStringEmpty(state))
			return;
		SharedPreferences settings = context.getSharedPreferences(context.getPackageName()+"_preferences",
				Context.MODE_PRIVATE);
		settings.edit().putString(PAD_STATE, state).commit();
	}
	
	synchronized public	static String getUpdateData(Context context, String id)
	{
		SharedPreferences settings = context.getSharedPreferences(context.getPackageName()+"_preferences",
				Context.MODE_PRIVATE);
		String data = settings.getString(UpdateData.UPDATE_DATA +id, "");			
		return data;
	}
	synchronized public	static void setUpdateData(Context context, UpdateData data)
	{
		SharedPreferences settings = context.getSharedPreferences(context.getPackageName()+"_preferences",
				Context.MODE_PRIVATE);
		settings.edit().putString(UpdateData.UPDATE_DATA + data.id, data.toString()).commit();
	}
	
	
	synchronized public	static String getDeskZhuLei(Context context)
	{
		SharedPreferences settings = context.getSharedPreferences(context.getPackageName()+"_preferences",
				Context.MODE_PRIVATE);
		String data = settings.getString(DESK_ZHULEI, "NONE");			
		return data;
	}
	synchronized public	static void setDeskZhuLei(Context context, String zhulei)
	{
		SharedPreferences settings = context.getSharedPreferences(context.getPackageName()+"_preferences",
				Context.MODE_PRIVATE);
		settings.edit().putString(DESK_ZHULEI, zhulei).commit();
	}
	synchronized public	static String getDeskZuidi(Context context)
	{
		SharedPreferences settings = context.getSharedPreferences(context.getPackageName()+"_preferences",
				Context.MODE_PRIVATE);
		String data = settings.getString(DESK_ZUIDI, "NONE");			
		return data;
	}
	synchronized public	static void setDeskZuidi(Context context, String zuidi)
	{
		SharedPreferences settings = context.getSharedPreferences(context.getPackageName()+"_preferences",
				Context.MODE_PRIVATE);
		settings.edit().putString(DESK_ZUIDI, zuidi).commit();
	}
	synchronized public	static String getDeskZhuleiming(Context context)
	{
		SharedPreferences settings = context.getSharedPreferences(context.getPackageName()+"_preferences",
				Context.MODE_PRIVATE);
		String data = settings.getString(DESK_ZHULEIMING, "NONE");			
		return data;
	}
	synchronized public	static void setDeskZhuleiming(Context context, String zhuleiming)
	{
		SharedPreferences settings = context.getSharedPreferences(context.getPackageName()+"_preferences",
				Context.MODE_PRIVATE);
		settings.edit().putString(DESK_ZHULEIMING, zhuleiming).commit();
	}
	synchronized public	static String getDeskID(Context context)
	{
		SharedPreferences settings = context.getSharedPreferences(context.getPackageName()+"_preferences",
				Context.MODE_PRIVATE);
		String data = settings.getString(DESK_ID, "NONE");			
		return data;
	}
	synchronized public	static void setDeskID(Context context, String id)
	{
		SharedPreferences settings = context.getSharedPreferences(context.getPackageName()+"_preferences",
				Context.MODE_PRIVATE);
		settings.edit().putString(DESK_ID, id).commit();
	}
	
	synchronized public	static String getIP(Context context)
	{
		SharedPreferences settings = context.getSharedPreferences(context.getPackageName()+"_preferences",
				Context.MODE_PRIVATE);
		String data = settings.getString(IP, ProtocolConst.ip);
		return data;
	}
	synchronized public	static void setIP(Context context, String ip)
	{
		SharedPreferences settings = context.getSharedPreferences(context.getPackageName()+"_preferences",
				Context.MODE_PRIVATE);
		settings.edit().putString(IP, ip).commit();
	}
}
